package scuts.collections;
import haxe.Timer;
import scuts.collections.immutable.BinTree;

import scuts.core.instances.OrdInt;
import utest.Assert;


class BinTreeTest 
{

  public function new() 
  {
    
  }
  
  public function testSize () {
    var t:BinTree<Int> = BinTrees.makeEmpty(OrdInt.get.compare);
    
    
    
    
    Assert.equals(1, t.insert(5).size());
    
    Assert.equals(2, t.insert(5).insert(2).size());
    
    Assert.equals(3, t.insert(5).insert(2).insert(7).size());
  }
  
   public function testRemove () {
    var t:BinTree<Int> = BinTrees.makeEmpty(OrdInt.get.compare);
    
    
    
    
    Assert.equals(0, t.insert(5).remove(function (t) return t == 5).size());
    
    Assert.equals(1, t.insert(5).insert(2).remove(function (t) return t == 2).size());
    
    Assert.equals(0, t.insert(5).insert(2).remove(function (t) return t == 2 || t == 5).size());
    
  }
}